using UnityEngine;
using PathX;

namespace PathX.Unity
{
    [RequireComponent(typeof(PathGridComponent)),DisallowMultipleComponent]
    public class UnityPathGrid : MonoBehaviour
    {
        [SerializeField]
        private PathGridComponent gridCom;
        private CellMatrix _matrix;

        public CellMatrix Matrix => _matrix;

        public ICellMatrixConfiguration Config => gridCom.GetCellMatrixConfiguration();

        private void Awake()
        {
            gridCom = GetComponent<PathGridComponent>();
        }

        private void OnEnable()
        {
            if (!Application.isPlaying)
                return;
            // if (_matrix == null)
            // {
            //   //  _matrix = CellMatrix.Create(gridCom.GetCellMatrixConfiguration(), gridCom.bakedData);
            // }
            //
            // PathGridManager.LoadGrid(_matrix);
        }

        // private void OnDisable()
        // {
        //     if (!Application.isPlaying)
        //         return;
        //     if (_matrix != null)
        //     {
        //         PathGridManager.UnloadGrid(_matrix);
        //     }
        // }
        //
        // public Cell GetCell(Vector3 pos)
        // {
        //     if(_matrix != null)
        //         return PathGridManager.GetCell(_matrix, pos);
        //     return default;
        // }
    }
}